IF EXISTS (SELECT * FROM sysobjects WHERE name = 'SelectCommandPeriodo' AND user_name(uid) = 'dbo')
	DROP PROCEDURE dbo.SelectCommandPeriodo
GO

CREATE PROCEDURE dbo.SelectCommandPeriodo
AS
	SET NOCOUNT ON;
SELECT     * FROM PERIODO
GO
--
--IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandPlan' AND user_name(uid) = 'dbo')
--	DROP PROCEDURE dbo.InsertCommandPlan
--GO
--
--CREATE PROCEDURE dbo.InsertCommandPlan
--(
--
--	@nombre nchar(100),
--	@fk_facultad int
--)
--AS
--DECLARE @ID INT
--SET @ID = (SELECT MAX(codigo) FROM [Plan])  
--                                                                                                                                                                                                            
--IF @ID IS NULL OR @ID=0                                                                                                                                                                                                                           
--	SET @ID = 1                                                                                                                                                                                                                                      
--ELSE                                                                                                                                                                                                                                                            
-- SET @ID = @ID + 1  
--	SET NOCOUNT OFF;
--INSERT INTO [Plan] ([codigo], [nombre], [fk_facultad]) VALUES (@id, @nombre, @fk_facultad)
GO


IF EXISTS (SELECT * FROM sysobjects WHERE name = 'UpdateCommandPlan' AND user_name(uid) = 'dbo')
	DROP PROCEDURE dbo.UpdateCommandPlan
GO

CREATE PROCEDURE dbo.UpdateCommandPlan
(
	@Original_codigo int,
	@nombre nchar(100),
	@fk_facultad int
)
AS
	SET NOCOUNT OFF;
UPDATE [Plan] 
	SET [nombre] = @nombre, 
	 [fk_facultad] = @fk_facultad
WHERE ([codigo] = @Original_codigo)
	
go

IF EXISTS (SELECT * FROM sysobjects WHERE name = 'DeleteCommandPlan' AND user_name(uid) = 'dbo')
	DROP PROCEDURE dbo.DeleteCommandPlan
GO

CREATE PROCEDURE dbo.DeleteCommandPlan
(
	@Original_codigo int
)
AS
	SET NOCOUNT OFF;
DELETE FROM [Plan] WHERE ([codigo] = @Original_codigo) 
GO
